<?php

define('APCU_PREFIX','go222_');//注意别的站不要重复

require __DIR__ . '/vendor/autoload.php';//composer方便导入各类库

(new \pidan\App())->initialize();//只引入app容器，及公共的配置

define('APCU_PV',APCU_PREFIX.'pv');//统计pv
apcu_store(APCU_PV, 0);

// 应用初始化
$http = new Swoole\Http\Server('0.0.0.0', 9503);
$http->on('Request', function ($request, $response) use($http) {
	if ($request->server['path_info'] == '/favicon.ico') {
		$response->end();
		return;
	}

	//根据pathinfo得出app controller action
	$path_info=$request->server['path_info'];
 	if($path_info=='/'){
		$path_info='/index/index/index';
	}
	list($app,$controller, $action) =explode('/',trim($path_info,'/'));

	$class='\\app\\'.$app.'\\controller\\'.ucfirst($controller);// \app\index\controller\Index
	$app=app();$contr=$app[$class];

	$contr->$action($request, $response);
	$i=apcu_inc(APCU_PV);
	//echo $i.'['.$http->master_pid.'-'.$http->manager_pid.'-'.$http->worker_id.']'."\n";
	//$app->G('end_'.$i,'','',100);

});
$http->start();







